<?php
/* -----------------------------------------------------------------
 *                        Aveghe My Blog
 * -----------------------------------------------------------------
 * Aveghe My Blog: made your blog easy!
 * Copyright (C) 2008 Elia Contini
 * 
 * Aveghe My Blog is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * Aveghe My Blog is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

require_once 'aveghe/views/helpers/MainMenu.php';

$meta    = $this->head('meta'   , 'admin', $this->preferences);
$style   = $this->head('style'  , 'admin', $this->preferences);
$favicon = $this->head('favicon', 'admin', $this->preferences);
$rss     = $this->head('rss'    , 'admin', $this->preferences);

$baseURL = BASE_URL;

$siteTitle = '<h1><a href="'.$baseURL.'/" title="">'.stripcslashes($this->preferences['site_title'])."</a></h1>\n";

$report = '';
if(count($this->report) > 0)
	{
		$report = "\n<div id=\"report\">\n\t".$this->report[0]."</div>\n";
	}

$helloLogout = $this->helloLogout($this->userInfo['user_name'], $baseURL);
$menu = $this->mainMenu(Aveghe_View_Helper_MainMenu::PROFILE, $baseURL);

$userName    = stripcslashes($this->userInfo['user_name']);
$userSurname = stripcslashes($this->userInfo['user_surname']);
$userEmail   = $this->userInfo['user_email'];
$userJabber  = $this->userInfo['user_jabber'];
$userAvatar  = $this->preferences['site_upload_directory'].'/';
$userDescription = stripslashes($this->userInfo['user_description']);

if(isset($this->userInfo['user_avatar']) && $this->userInfo['user_avatar'] != '' && file_exists($userAvatar.($this->userInfo['user_avatar'])))
	$userAvatar .= $this->userInfo['user_avatar'];
else
	$userAvatar .= 'user.png';



$content = <<< CONTENT

	<h2>Il mio profilo</h2>
	
	<form id="formUserImage" action="$baseURL/user/update-avatar" method="post" enctype="multipart/form-data">
		<fieldset>
			<legend>Immagine utente</legend>
			<p class="borderTop">
				<img src="$baseURL/$userAvatar" width="100" height="100" alt="Una immagine di $userName" />
				
				<label for="userAvatar">Carica immagine</label>
				<input class="file" type="file" id="userAvatar" name ="userAvatar" />
				
				<input type="submit" class="submit" value="Salva" />
			</p>
		</fieldset>
	</form>
	
	<form id="formUserInfo" action="$baseURL/user/update-info" method="post">
		<fieldset>
			<legend>Informazioni utente</legend>
			<p class="borderTop">
				<label for="userName">Nome</label>
				<input type="text" class="text" id="userName" name="userName" value="$userName" />
				
				<label for="userSurname">Cognome</label>
				<input type="text" class="text" id="userSurname" name="userSurname" value="$userSurname" />
				
				<label for="userEmail">E-Mail</label>
				<input type="text" class="text" id="userEmail" name="userEmail" value="$userEmail" />
				
				<label for="userJabber">Account Jabber/GoogleTalk</label>
				<input type="text" class="text" id="userJabber" name="userJabber" value="$userJabber" />
				
				<input type="submit" class="submit" value="Salva" />
			</p>
		</fieldset>
	</form>
	
	<form id="formUserDescription" action="$baseURL/user/update-description" method="post">
		<fieldset>
			<legend>Descrizione utente</legend>
			<p class="borderTop">
				<label for="userDescription">Descrizione</label>
				<textarea cols="40" rows="8" id="userDescription" name="userDescription">$userDescription</textarea>
				
				<input type="submit" class="submit" value="Salva" />
			</p>
		</fieldset>
	</form>
	
	<form id="formUserPassword" action="$baseURL/user/update-password" method="post">
		<fieldset>
			<legend>Cambia password</legend>
			<p class="borderTop">
				<label for="userPassword">Nuova password</label>
				<input type="password" class="text" id="userPassword" name="userPassword" />
				
				<label for="userPasswordCheck">Ridigita password</label>
				<input type="password" class="text" id="userPasswordCheck" name="userPasswordCheck" />
				
				<input type="submit" class="submit" value="Salva" />
			</p>
		</fieldset>
	</form>

CONTENT;

include 'aveghe/themes/admin/'.$this->preferences['site_admin_theme'].'/template_admin.xhtml';
?>